package ru.jkff.jalgebra.order;

/**
 * User: jkff
 * Date: Aug 22, 2009
 * Time: 12:36:40 PM
 */
public abstract class PartialOrder<T> extends Equivalence<T> {
    public abstract boolean isLessOrEqual(T a, T b);

    public /* non-final */ boolean areEqual(T a, T b) {
        return isLessOrEqual(a,b) && isLessOrEqual(b,a);
    }

    public PartialOrder<T> flip() {
        final PartialOrder<T> us = this;
        return new PartialOrder<T>() {
            public boolean isLessOrEqual(T a, T b) {
                return us.isLessOrEqual(b,a);
            }
        };
    }
}
